fix: make client-owned web fetch discoverable (#252) - #263
Open
ankitranjan7 wants to merge 1 commit into
Open
Conversation
`web fetch` always worked via the main.ts fast path but was invisible to `--help`, `list`, `cli-manifest.json`, and completions unless the `web` plugin was installed, and `web fetch -h` threw instead of printing help. Register the command from clis/web/fetch.js via a makeWebFetchCommand() factory so build-manifest and filesystem discovery both see it, and keep execution on the fast path so hosted mode never cloud-routes it. The fast path now honours the flags its help advertises: -f/--format for output and structured --help, an error for unsupported formats, and an error for a flag-shaped --timeout/--max-chars value instead of coercing it to 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. This review is advisory and does not block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #252.
The problem
webcmd web fetchalways works, but the CLI never tells you it exists.The command is intercepted on the client-owned fast path in
src/main.ts:79, before adapter discovery — so it runs on a fresh install with zero plugins. It just isn't listed anywhere, and asking for help throws:So the only way to discover a built-in command is to already know it.
What I changed
clis/web/fetch.js— registers the command through a newmakeWebFetchCommand()factory, so bothbuild-manifestand the runtime filesystem scan pick it up.src/discovery.ts— the module pattern now matchesmake<Pascal>Command(, the same conventionsrc/build-manifest.ts:48already used.cli-manifest.json— gains the generatedweb/fetchentry. It regenerates byte-identical,check:hosted-contractpasses, andhosted-contract.jsonis unchanged because this command is not browser-based.src/fetch/command.ts— now that help is real, the fast path honours what it advertises:-f/--formatfor output (markdown still the default), structured--help -f yaml|json, an error on an unsupported format instead of silently falling back to a table, and an error when--timeout/--max-charsis given a flag-shaped value instead of quietly coercing it to1.The fast path itself stays exactly where it was — execution never touches the registry, so hosted mode still never cloud-routes this command.
Proof
webcmd --helpwebwebunder Site adapterswebcmd listfetch [public] … [builtin]webcmd list -f jsonwebcmd web fetch -hArgumentErrorwebcmd --get-completions web ''fetch,fetch-browserVerified against a rebuilt
dist. Four new tests insrc/fetch/command.test.tscover the-foutput path, structured help, the format rejection and the--timeout -5rejection. Full suite passes excepttests/e2e/plugin-management.test.ts, which clones plugins over the network and fails identically onmain(fixed separately in #267).Not in this PR
ArgumentErrorstill prints a raw stack trace on the fast path.clis/missing frompackage.jsonfiles. Unreachable here while theargv[0] === 'web' && argv[1] === 'fetch'prefix holds, and pre-existing forfetch-browser. Fixed in fix: ship web fetch-browser so the blocked-fetch escalation works (#247) #271.🤖 Generated with Claude Code